package com.md.rps.action.actions;

import com.md.rps.mybatis.model.EMPLOYEE;
import com.md.rps.service.EmployeeOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class EmployeeAction {
    @Autowired
    private EmployeeOperator employeeOperator;

    // 获取所有医生列表
    @GetMapping("getDoctorsList")
    public List<EMPLOYEE> getDoctorsList(@RequestParam("start") int start,
                                         @RequestParam("end") int end){
        return employeeOperator.getDoctorsList(start, end);
    }

    // 根据科室查看医生列表
    @GetMapping("getDoctorsListByDept")
    public List<EMPLOYEE> getDoctorsListByDept(@RequestParam("dept") int dept){
        return employeeOperator.getDoctorsListByDept(dept);
    }

    // 查看指定医生
    @GetMapping("getDoctor")
    public EMPLOYEE getDoctor(@RequestParam("id") int id){
        return employeeOperator.getDoctor(id);
    }

    // 获取所有护士列表
    @GetMapping("getNurseList")
    public List<EMPLOYEE> getNurseList(@RequestParam("start") int start,
                                       @RequestParam("end") int end){
        return employeeOperator.getNurseList(start, end);
    }

    // 获取所有管理人员列表
    @GetMapping("getManagerList")
    public List<EMPLOYEE> getManagerList(@RequestParam("start") int start,
                                         @RequestParam("end") int end){
        return employeeOperator.getManagerList(start,end);
    }

    // 添加员工
    @PostMapping("addEmployee")
    public int addEmployee(EMPLOYEE employee){
        return employeeOperator.addEmployee(employee);
    }

    // 修改员工
    @PostMapping("updateEmployee")
    public int updateEmployee(EMPLOYEE employee){
        return employeeOperator.updateEmployee(employee);
    }

    // 删除员工
    @PostMapping("deleteEmployee")
    public int deleteEmployee(int id){
        return employeeOperator.deleteEmployee(id);
    }
}
